<template>
  <div class="wrapper">
    <swiper :options="swiperOptions" ref="mySwiper" v-if="showSwiper">
        <swiper-slide v-for="item of list" :key="item.id">
          <img class="swiper-img" :src="item.imgUrl" />
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
<!--        <div class="swiper-button-prev" slot="button-prev" @click="prev"></div>
        <div class="swiper-button-next" slot="button-next" @click="next"></div> -->
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        loop:true,
        autoplay: 3000,
        autoplayDisableOnInteraction:false,
        navigation: {
          prevEl: '.swiper-button-next',
          nextEl: '.swiper-button-prev',
        }
      }
    }
  },
  methods: {
  		prev() {
  			this.$refs.mySwiper.swiper.slidePrev();
  		},
  		next() {
  			this.$refs.mySwiper.swiper.slideNext();
  		}
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
    background : #fff
  .wrapper
    width : 100%
    overflow : hidden
    height :0
    padding-bottom : 37%
    background : #000000
    .swiper-img
      width: 100%
</style>
